﻿Imports System.Data
Imports System.Data.OleDb

Public Class ProfileEditProfile
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("myFirstDatabase").ConnectionString)
        Dim SqlString As String = "SELECT * FROM tblprofile WHERE Neighbor=@f1"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", User.Identity.Name)
        oleDbConn.Open()
        Dim dr As OleDbDataReader = cmd.ExecuteReader()
        If dr.HasRows Then
            dr.Read()
            If Not IsDBNull(dr("First Name")) Then txtFname.Text = dr("FirstName")
            If Not IsDBNull(dr("Last Name")) Then txtLname.Text = dr("LastName")
            If Not IsDBNull(dr("Neighbor")) Then txtNeighbor.Text = dr("Neighbor")

        End If

    End Sub

    Protected Sub btnProfile_Click(sender As Object, e As System.EventArgs) Handles btnProfile.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("myFirstDatabase").ConnectionString)
        Dim SqlString As String = "UPDATE tblprofile SET (firstname,lastname,Content,DateSubmitted,Topic) Values (@f1,@f2,@f3,@f4,@f5)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        Dim SubmittedDate As DateTime = Now()
        Dim format As String = "ddd MMM yyyy"
        cmd.CommandType = CommandType.Text
        ' cmd.Parameters.AddWithValue("@f1", txtfirstname.Text)

    End Sub
End Class
